package com.minelx.table.core.series.source;

public class OffsetGridSource<E> implements GridSource<E> {
	private final GridSource<E> decorated;

	private final int x;

	private final int y;

	public OffsetGridSource(GridSource<E> decorated, int x, int y) {
		this.decorated = decorated;
		this.x = x;
		this.y = y;
	}

	@Override
	public E at(long rowAt, long columnAt) {
		return decorated.at(rowAt + y, columnAt + x);
	}

	@Override
	public long availableRow() {
		return decorated.availableRow() - y;
	}

	@Override
	public long availableColumn() {
		return decorated.availableColumn() - x;
	}
}
